package cn.lazyturtle.bugpush.service.dingdingcallback;

import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * <p>
 * CallBackFactory :
 * </p>
 *
 * @author cwh
 * @since 2021-10-25
 */
public class DingDingCallBackHandlerFactory {
    private static final Map<String, DingDingCallBackHandler> STRATEGY_MAP = new HashMap<>();

    public static DingDingCallBackHandler getInvokeStrategy(String name){
        return STRATEGY_MAP.get(name);
    }

    public static void register(String name, DingDingCallBackHandler handler){
        if (Objects.isNull(handler) || !StringUtils.hasText(name)){
            return;
        }
        STRATEGY_MAP.put(name,handler);
    }
}
